package com.ruoyi.web.controller.cs;

import java.util.List;

import com.ruoyi.common.core.controller.BasicsController;
import com.ruoyi.common.core.domain.Response;
import com.ruoyi.common.core.page.ResponsePageInfo;
import com.ruoyi.common.utils.poi.Excel2Util;
import com.ruoyi.cs.domain.TGoodsUpgrate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cs.domain.TLog;
import com.ruoyi.cs.service.ITLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统登录信息Controller
 * 
 * @author ruoyi
 * @date 2021-03-25
 */
@Api(tags = {"系统登录信息"})
@RestController
@RequestMapping("/cs/log")
public class TLogController extends BasicsController
{
    @Autowired
    private ITLogService tLogService;

    /**
     * 查询系统登录信息列表
     */
    @ApiOperation("查询系统登录信息列表")
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public ResponsePageInfo<TLog> list(TLog tLog)
    {
        startPage();
        List<TLog> list = tLogService.selectTLogList(tLog);
        return toResponsePageInfo(list);
    }

    /**
     * 导出系统登录信息列表
     */
    @ApiOperation("导出系统登录信息列表")
    @PreAuthorize("@ss.hasPermi('system:log:export')")
    @Log(title = "系统登录信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public Response<String> export(TLog tLog)
    {
        List<TLog> list = tLogService.selectTLogList(tLog);
        Excel2Util<TLog> util = new Excel2Util<TLog>(TLog.class);
        return util.exportExcel(list, "log");
    }

    /**
     * 获取系统登录信息详细信息
     */
    @ApiOperation("获取系统登录信息详细信息")
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{rzId}")
    public Response<TLog> getInfo(
            @ApiParam(name = "rzId", value = "系统登录信息ID", required = true)
            @PathVariable("rzId") String rzId)
    {
        return Response.success(tLogService.selectTLogById(rzId));
    }

    /**
     * 新增系统登录信息
     */
    @ApiOperation("新增系统登录信息")
    @PreAuthorize("@ss.hasPermi('system:log:add')")
    @Log(title = "系统登录信息", businessType = BusinessType.INSERT)
    @PostMapping
    public Response<Integer> add(@RequestBody TLog tLog)
    {
        return toResponse(tLogService.insertTLog(tLog));
    }

    /**
     * 修改系统登录信息
     */
    @ApiOperation("修改系统登录信息")
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "系统登录信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public Response<Integer> edit(@RequestBody TLog tLog)
    {
        return toResponse(tLogService.updateTLog(tLog));
    }

    /**
     * 删除系统登录信息
     */
    @ApiOperation("删除系统登录信息")
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "系统登录信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rzIds}")
    public Response<Integer> remove(
            @ApiParam(name = "rzIds", value = "需要删除的系统登录信息ID", required = true)
            @PathVariable String[] rzIds)
    {
        return toResponse(tLogService.deleteTLogByIds(rzIds));
    }
}
